<#assign base=request.contextPath />
<#assign oneLabel="ERP管理">

<#assign twoLabel="物料管理">
<#assign twoUrl=base+"/materiel/list">

<#assign leafLabel="物料明细">
<!DOCTYPE html>
<html lang="en">
<head>
	<link rel="stylesheet" href="${base}/static/assets/css/chosen.css" />
	<#include "/commons/headImport.ftl">
</head>
<body>
<#include "/commons/header.ftl">
<form class="form-horizontal" name="formName" method="post">
	<#include "/commons/hiddenField.ftl">
	<@spring.formHiddenInput "materielDO.id"/>
	<div class="row">
		<div class="col-xs-12">
			<div class="form-group">
				<label class="col-sm-2 control-label no-padding-right">
					供应商:
				</label>
				<div class="col-sm-2">
					<div class="help-block col-xs-12 col-sm-reset inline">${(materielDO.suppilerDO.name)!'--'}</div>
				</div>
				<label class="col-sm-1 control-label no-padding-right">
					名称:
				</label>
				<div class="col-sm-2">
					<div class="help-block col-xs-12 col-sm-reset inline">${materielDO.name!'--'}</div>
				</div>
				<label class="col-sm-1 control-label no-padding-right">
					规格型号:
				</label>
				<div class="col-sm-2">
					<div class="help-block col-xs-12 col-sm-reset inline">${materielDO.spec!'--'}</div>
				</div>
			</div>
			<div class="space-4"></div>
							
			<div class="form-group">
				<label class="col-sm-2 control-label no-padding-right">
					单位:
				</label>
				<div class="col-sm-2">
					<div class="help-block col-xs-12 col-sm-reset inline">${materielDO.unit!'--'}</div>
				</div>
				<label class="col-sm-1 control-label no-padding-right">
					库存:
				</label>
				<div class="col-sm-2">
					<div class="help-block col-xs-12 col-sm-reset inline">${materielDO.quantity!'--'}</div>
				</div>
				<label class="col-sm-1 control-label no-padding-right">
					状态:
				</label>
				<div class="col-sm-2">
					<div class="help-block col-xs-12 col-sm-reset inline">${(statusMap['${materielDO.status}']!'--')}</div>
				</div>
			</div>
			<div class="space-4"></div>
			
			<div class="table-responsive">
				<p>
					<a class="btn btn-minier btn-success" id="materiel_id">
						<i class="icon-edit bigger-110"></i>采购入库
					</a>
				</p>
				<table class="table table-striped table-bordered">
					<tr>
						<th width="5%">#</th>
						<th width="15%">单价</th>
						<th width="15%">当前库存</th>
						<th width="15%"><i class="icon-time bigger-110 hidden-480"></i>初次采购时间</th>
						<th width="20%">备注</th>
						<th width="30%"></th>
						
					</tr>
					<#if materielDO.detailList??>
					<#list materielDO.detailList as detail>
					<tr>
						<td class="center">${detail_index+1}</td>
						<td>${(detail.unitPrice/100.0)?string.currency}</td>
						<td>${detail.quantity!0}</td>
						<td>${detail.gmtCreate?string('yyyy/MM/dd HH:mm')}</td>
						<td>${detail.remark}</td>
						<td>
							<div class="visible-md visible-lg hidden-sm hidden-xs btn-group">
								<a class="btn btn-minier btn-success" href="javascript:openIn('${base}/materielDetail/editIn/${detail.id}');" title="入库">
									<i class="icon-edit bigger-120"></i>入库
								</a>
								<a class="btn btn-minier btn-success" href="javascript:openOut('${base}/materielDetail/editOut/${detail.id}');" title="出库">
									<i class="icon-edit bigger-120"></i>出库
								</a>
								<a class="btn btn-minier btn-success" href="javascript:openEdit('${base}/materielDetail/editQuantity/${detail.id}');" title="调整库存">
									<i class="icon-exchange bigger-120"></i>调整库存
								</a>
							</div>
						</td>
					</tr>
					</#list>
					</#if>
				</table>
			</div>
		</div><!-- /.col -->
	</div><!-- /.row -->
</form>
<div class="hr hr32 hr-dotted"></div>
<div class="clearfix">
	<div class="col-md-offset-2 col-md-9">
		<button class="btn btn-xs return_class" type="button" url="${base}/materiel/list">
			<i class="icon-reply bigger-110"></i>返回
		</button>
	</div>
</div>
<#include "/commons/footer.ftl">
<script src="${base}/static/assets/js/chosen.jquery.min.js"></script>
<script src="${base}/static/layer/layer.js"></script>
<script>
	jQuery(function($) {
		$(".chosen-select").chosen();
		
		$("#materiel_id").click(function(){
			layer.open({
		      type: 2,
		      title: '采购入库',
		      maxmin: true,
		      shadeClose: true, //点击遮罩关闭层
		      area : ['800px' , '450px'],
		      content: '${base}/materielDetail/add?materielId=${materielDO.id!0}'
		    });
	   });
	});
	
	function openIn(url) {
		layer.open({
	      type: 2,
	      title: '采购入库',
	      maxmin: true,
	      shadeClose: true, //点击遮罩关闭层
	      area : ['800px' , '450px'],
	      content: url
		});
	}
	
	function openOut(url) {
		layer.open({
	      type: 2,
	      title: '项目出库',
	      maxmin: true,
	      shadeClose: true, //点击遮罩关闭层
	      area : ['800px' , '520px'],
	      content: url
		});
	}
	
	function openEdit(url) {
		layer.open({
	      type: 2,
	      title: '库存调整',
	      maxmin: true,
	      shadeClose: true, //点击遮罩关闭层
	      area : ['800px' , '400px'],
	      content: url
		});
	}
</script>
</body>
</html>
